#include "Util.hpp"
#include "Sock.hpp"
#include "Reactor.hpp"
#include "Service.hpp"

int Accepter(Event *ev)
{
    cout << "有新的连接到来" << endl;
    while (true)
    {
        int sock = Sock::Accept(ev->_sock);
        if (sock < 0)
        {
            cerr << "Accept Done" << endl;
            break;
        }
        SetNonBlock(sock);
        Event *new_ev = new Event(sock);
        new_ev->_sock = sock;
        new_ev->R = ev->R;
        new_ev->CallbackRegister(Recver, Sender, Errorer);
        new_ev->R->InsertEvent(new_ev, EPOLLIN | EPOLLET);
    }
    return 1;
}